﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Prr;

namespace necklace
{
    public partial class Form1 : Form
    {
        int price = 0;
        int weight = 0;


        public Form1()
        {
            
            InitializeComponent();
            
        }

        public void Add(string name, int weight, int price)
        {
            richTextBox1.Text += name + " " + weight + " карат = " + price + " у.е.\n";
            this.price += price;
            this.weight += weight;
            label1.Text = this.price.ToString();
            label4.Text = this.weight.ToString();
        }

        public void adding(Stones vaget)
        {
            try
            {
                int weight = int.Parse(textBox1.Text);
                Add(vaget.getName(), weight, vaget.getprice() * weight);
            }
            catch (System.FormatException error)
            { 
                MessageBox.Show("Вы не ввели вес.");
            }            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            adding(new Diamond());
        }

        private void button2_Click(object sender, EventArgs e)
        {
            adding(new Emerald());
        }

        private void button3_Click(object sender, EventArgs e)
        {
            adding(new Agate());
        }

        private void button4_Click(object sender, EventArgs e)
        {
            adding(new Amethyst());
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button5_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = null;
            this.price = 0;
            this.weight = 0;
        }
//-----------------------------------------------------------------

           // adding(new Diamond());


        
    
    }
}
